<a (click)="edit()">
  <i nz-icon nzType="plus"></i>
  添加
</a>

<nz-row [nzGutter]="[8,8]" cdkDropList (cdkDropListDropped)="drop($event)">
  <div nz-col [nzSpan]="24"
       *ngFor="let data of items; let i=index" cdkDrag>
    <nz-card nzSize="small" nzHoverable [nzExtra]="extraTemplate" (click)="edit(data)">
        {{data.point}} = {{data.expression || data.value}}
      <span *ngIf="data.delay">延迟{{data.delay}}ms</span>
    </nz-card>
    <ng-template #extraTemplate>
      <a title="移动" cdkDragHandle>
        <i nz-icon nzType="drag" nzTheme="outline"></i>
      </a>
      <nz-divider nzType="vertical"></nz-divider>
      <a title="复制" (click)="copy(i); $event.stopPropagation()">
        <i nz-icon nzType="copy" nzTheme="outline"></i>
      </a>
      <nz-divider nzType="vertical"></nz-divider>
      <a title="删除" nz-popconfirm nzPopconfirmTitle="确定删除?" (nzOnConfirm)="remove(i)" (click)="$event.stopPropagation()">
        <i nz-icon nzType="delete" nzTheme="outline"></i>
      </a>
    </ng-template>
  </div>
</nz-row>

<nz-modal [(nzVisible)]="showModal" nzTitle="编辑指令" (nzOnOk)="onOk()" (nzOnCancel)="showModal=false">
  <ng-container *nzModalContent>
    <form [formGroup]="formGroup">
      <nz-form-item>
        <nz-form-label [nzSpan]="5">数据点</nz-form-label>
        <nz-form-control [nzSpan]="12" nzErrorTip="">
<!--          <input nz-input formControlName="point" required/>-->
          <nz-select formControlName="point" nzSize="small" required>
            <nz-option [nzValue]="pt.name" [nzLabel]="pt.label + '('+pt.name+')'" *ngFor="let pt of points"></nz-option>
          </nz-select>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSpan]="5">值</nz-form-label>
        <nz-form-control [nzSpan]="12" nzErrorTip="">
          <nz-input-number formControlName="value"></nz-input-number>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSpan]="5">延迟</nz-form-label>
        <nz-form-control [nzSpan]="12" nzErrorTip="">
          <nz-input-number formControlName="delay"></nz-input-number>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label [nzSpan]="5">表达式</nz-form-label>
        <nz-form-control [nzSpan]="12" nzErrorTip="">
          <input nz-input formControlName="expression" required/>
        </nz-form-control>
      </nz-form-item>

    </form>
  </ng-container>
</nz-modal>
